DateTimeValue

Basic and Crystal syntax.

The CDateTime and DateTime functions are equivalent to DateTimeValue. However, DateTime can only be used in Crystal syntax since it is a type name in Basic syntax.

Overloads
Arguments

DateTimeValue (date)

  • date is a Date value.

DateTimeValue (date, time)

  • date is a Date value.
  • time is a Time value.

DateTimeValue (number)

  • number represents a number of days from December 30, 1899, example: 20 represents 20 days from December, 1899, which is January 19, 1900.

DateTimeValue (string)

  • string represents a date and time, example: "September 15, 1999, 10:45a.m."

DateTimeValue (year, month, day)

DateTimeValue (year, month, day, hour, min, sec)

  • year is a whole number representing a calendar year, example: 1996.
  • month is a whole number representing a month, example: 1 for January.
  • day is a whole number representing a day of the month, example: 10.
  • hour is a whole number representing an hour of the day, example: 12.
  • min is a whole number representing a minute, example: 59.
  • sec is a whole number representing seconds, example: 30.

Returns

DateTime value.

Action

DateTimeValue (date) returns a DateTime value given a Date value, assigning 12:00:00 AM for the time portion for the returned DateTime value.

DateTimeValue (date, time) returns a DateTime value given a Date and a Time value.

DateTimeValue (number) returns a DateTime value given a number that specifies the number of days from December 30, 1899. Number can be positive or negative, and can be fractional.

DateTimeValue (string) returns a DateTime value given a string that specifies a date and time; various formats of the string are supported.

DateTimeValue (YYYY, MM, DD) returns a DateTime value given numeric arguments for the year, month and day. Assigns 12:00:00 AM for the time portion for the returned DateTime value.

DateTimeValue (YYYY, MM, DD, HH, MM, SS) returns a DateTime value given numeric arguments for the year, month, day, hour, minute and second.

Examples

The following examples are applicable to both Basic and Crystal syntax:

DateTimeValue ("10/4/1999 10:20am")

Returns the DateTime value October 4, 1999 10:20:00 am

DateTimeValue (12.5)

Returns the DateTime value January 11, 1900 12:00:00 pm

DateTimeValue (-2.5)

Returns the DateTime value December 27, 1899, 12:00:00 pm

DateTimeValue (CDate ("Dec. 25, 1999"))

Returns the DateTime value December 25, 1999 12:00:00 am

DateTimeValue (CDate ("November 10, 1999"), CTime("12:20am"))

Returns the DateTime value November 10, 1999 12:20:00 am

DateTimeValue (1945, 8, 21, 0, 0, 0)

Returns the DateTime value August 21, 1945 12:00:00 am

DateTimeValue (1945, 8, 21, 10, 0, 0)

Returns the DateTime value August 21, 1945 10:00:00 am

Comments

You can use the IsDateTime function to check if a String argument can be converted to a DateTime before doing the actual conversion. That way, if the conversion cannot be done, you can handle the situation appropriately.



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com